package com.pjh.shitang.handlers;

import com.pjh.shitang.utils.vo.returns.ResponseBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author yueyinghaibao
 * @date 2022/5/1
 */
@Slf4j
@RestControllerAdvice
public class RestExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public ResponseBody<String> exception(Exception e) {
        log.warn(e.toString());
        return ResponseBody.error(e.getMessage());
    }
}
